package com.alm.web.controller.alm.devcron;

import com.alm.common.core.domain.AjaxResult;
import com.alm.handle.core.domain.entity.rq.DevCronEditRq;
import com.alm.handle.core.domain.entity.rq.DevCronQueryRq;
import com.alm.handle.service.AlmDevCronService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * 设备定时任务管理控制器
 *
 * @author 詹泽峰
 * @date 2024/07/04 09:18
 */
@RestController
@RequestMapping("/alm/dev_cron")
public class AlmDevCronController {
    @Resource
    private AlmDevCronService almDevCronService;

    @PreAuthorize("@ss.hasRole('common')")
    @PostMapping("/list")
    public AjaxResult getDevCronList(@RequestBody DevCronQueryRq rq) {
        return almDevCronService.getDevCronList(rq);
    }

    @PreAuthorize("@ss.hasRole('common')")
    @PostMapping("/query")
    public AjaxResult getDevCronById(@RequestBody DevCronQueryRq rq) {
        return almDevCronService.getDevCronById(rq);
    }

    @PreAuthorize("@ss.hasRole('common')")
    @PostMapping("/add")
    public AjaxResult addDevCron(@RequestBody DevCronEditRq rq) {
        return almDevCronService.addDevCron(rq);
    }

    @PreAuthorize("@ss.hasRole('common')")
    @PostMapping("/del")
    public AjaxResult delDevCron(@RequestBody DevCronEditRq rq) {
        return almDevCronService.delDevCron(rq);
    }

    @PreAuthorize("@ss.hasRole('common')")
    @PostMapping("/edit")
    public AjaxResult editDevCron(@RequestBody DevCronEditRq rq) {
        return almDevCronService.editDevCron(rq);

    }
    @PreAuthorize("@ss.hasRole('common')")
    @PostMapping("/addGroupCron")
    public AjaxResult setCronByDevGroup(@RequestBody DevCronEditRq rq) {
        return almDevCronService.setCronByDevGroup(rq);

    }
    @PreAuthorize("@ss.hasRole('common')")
    @PostMapping("/editSwitch")
    public AjaxResult editCronSwitch(@RequestBody DevCronEditRq rq) {
        return almDevCronService.editCronSwitch(rq);
    }

    @PreAuthorize("@ss.hasRole('common')")
    @PostMapping("/refresh")
    public AjaxResult refresh(@RequestBody DevCronQueryRq rq) {
        return almDevCronService.refresh(rq);
    }
}
